--
-- PostgreSQL database dump
--

-- Dumped from database version 9.0.4
-- Dumped by pg_dump version 9.0.4
-- Started on 2012-03-01 22:22:33

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- TOC entry 7 (class 2615 OID 77561)
-- Name: acesso; Type: SCHEMA; Schema: -; Owner: positrot
--

CREATE SCHEMA acesso;


ALTER SCHEMA acesso OWNER TO positrot;

--
-- TOC entry 8 (class 2615 OID 77562)
-- Name: adm; Type: SCHEMA; Schema: -; Owner: positrot
--

CREATE SCHEMA adm;


ALTER SCHEMA adm OWNER TO positrot;

--
-- TOC entry 9 (class 2615 OID 77286)
-- Name: data; Type: SCHEMA; Schema: -; Owner: positrot
--

CREATE SCHEMA data;


ALTER SCHEMA data OWNER TO positrot;

--
-- TOC entry 10 (class 2615 OID 77563)
-- Name: log; Type: SCHEMA; Schema: -; Owner: positrot
--

CREATE SCHEMA log;


ALTER SCHEMA log OWNER TO positrot;

--
-- TOC entry 396 (class 2612 OID 11574)
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres
--

CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql;


ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres;

SET search_path = log, pg_catalog;

--
-- TOC entry 22 (class 1255 OID 77564)
-- Dependencies: 396 10
-- Name: fn_delete_av_sujeito_amostras(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_av_sujeito_amostras() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.av_sujeito_amostras
    where data.av_sujeito_amostras.idav_sujeito_amostras
     = old.idav_sujeito_amostras;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_av_sujeito_amostras() OWNER TO postgres;

--
-- TOC entry 23 (class 1255 OID 77565)
-- Dependencies: 10 396
-- Name: fn_delete_av_sujeito_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_av_sujeito_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.av_sujeito_dados
    where data.av_sujeito_dados.idav_sujeito_dados
     = old.idav_sujeito_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_av_sujeito_dados() OWNER TO postgres;

--
-- TOC entry 24 (class 1255 OID 77566)
-- Dependencies: 10 396
-- Name: fn_delete_av_sujeito_fase_cont(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_av_sujeito_fase_cont() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.av_sujeito_fase_cont
    where data.av_sujeito_fase_cont.idav_sujeito_fase_cont
     = old.idav_sujeito_fase_cont;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_av_sujeito_fase_cont() OWNER TO postgres;

--
-- TOC entry 25 (class 1255 OID 77567)
-- Dependencies: 10 396
-- Name: fn_delete_av_sujeito_info_cli(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_av_sujeito_info_cli() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.av_sujeito_info_cli
    where data.av_sujeito_info_cli.idav_sujeito_info_cli
     = old.idav_sujeito_info_cli;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_av_sujeito_info_cli() OWNER TO postgres;

--
-- TOC entry 26 (class 1255 OID 77568)
-- Dependencies: 396 10
-- Name: fn_delete_av_sujeito_laboratorio(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_av_sujeito_laboratorio() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.av_sujeito_laboratorio
    where data.av_sujeito_laboratorio.idav_sujeito_laboratorio
     = old.idav_sujeito_laboratorio;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_av_sujeito_laboratorio() OWNER TO postgres;

--
-- TOC entry 27 (class 1255 OID 77569)
-- Dependencies: 10 396
-- Name: fn_delete_av_sujeito_sintomas(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_av_sujeito_sintomas() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.av_sujeito_sintomas
    where data.av_sujeito_sintomas.idav_sujeito_sintomas = old.idav_sujeito_sintomas;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_av_sujeito_sintomas() OWNER TO postgres;

--
-- TOC entry 28 (class 1255 OID 77570)
-- Dependencies: 10 396
-- Name: fn_delete_coleta_pk_coletas_de_sangue(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_coleta_pk_coletas_de_sangue() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.coleta_pk_coletas_de_sangue
    where data.coleta_pk_coletas_de_sangue.idcoleta_pk_coletas_de_sangue = old.idcoleta_pk_coletas_de_sangue;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_coleta_pk_coletas_de_sangue() OWNER TO postgres;

--
-- TOC entry 29 (class 1255 OID 77571)
-- Dependencies: 10 396
-- Name: fn_delete_coleta_pk_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_coleta_pk_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.coleta_pk_dados
    where data.coleta_pk_dados.idcoleta_pk_dados = old.idcoleta_pk_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_coleta_pk_dados() OWNER TO postgres;

--
-- TOC entry 30 (class 1255 OID 77572)
-- Dependencies: 396 10
-- Name: fn_delete_desfecho_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_desfecho_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.desfecho_dados
    where data.desfecho_dados.iddesfecho_dados = old.iddesfecho_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_desfecho_dados() OWNER TO postgres;

--
-- TOC entry 31 (class 1255 OID 77573)
-- Dependencies: 396 10
-- Name: fn_delete_falencia_trat_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_falencia_trat_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.falencia_trat_dados
    where data.falencia_trat_dados.idfalencia_trat_dados
     = old.idfalencia_trat_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_falencia_trat_dados() OWNER TO postgres;

--
-- TOC entry 32 (class 1255 OID 77574)
-- Dependencies: 10 396
-- Name: fn_delete_falha_inclusao_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_falha_inclusao_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.falha_inclusao_dados
    where data.falha_inclusao_dados.idfalha_inclusao_dados = old.idfalha_inclusao_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_falha_inclusao_dados() OWNER TO postgres;

--
-- TOC entry 33 (class 1255 OID 77575)
-- Dependencies: 396 10
-- Name: fn_delete_gravidez_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_gravidez_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.gravidez_dados
    where data.gravidez_dados.idgravidez_dados
     = old.idgravidez_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_gravidez_dados() OWNER TO postgres;

--
-- TOC entry 34 (class 1255 OID 77576)
-- Dependencies: 396 10
-- Name: fn_delete_hipersen_avaliacaoad(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_hipersen_avaliacaoad() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.hipersen_avaliacaoad
    where data.hipersen_avaliacaoad.idhipersen_avaliacaoad = old.idhipersen_avaliacaoad;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_hipersen_avaliacaoad() OWNER TO postgres;

--
-- TOC entry 35 (class 1255 OID 77577)
-- Dependencies: 396 10
-- Name: fn_delete_hipersen_avaliacaodiet(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_hipersen_avaliacaodiet() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.hipersen_avaliacaodiet
    where data.hipersen_avaliacaodiet.idhipersen_avaliacaodiet = old.idhipersen_avaliacaodiet;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_hipersen_avaliacaodiet() OWNER TO postgres;

--
-- TOC entry 36 (class 1255 OID 77578)
-- Dependencies: 396 10
-- Name: fn_delete_hipersen_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_hipersen_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.hipersen_dados
    where data.hipersen_dados.idhipersen_dados = old.idhipersen_dados;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_hipersen_dados() OWNER TO postgres;

--
-- TOC entry 37 (class 1255 OID 77579)
-- Dependencies: 396 10
-- Name: fn_delete_hipersen_exameslab(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_hipersen_exameslab() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.hipersen_exameslab
    where data.hipersen_exameslab.idhipersen_exameslab = old.idhipersen_exameslab;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_hipersen_exameslab() OWNER TO postgres;

--
-- TOC entry 38 (class 1255 OID 77580)
-- Dependencies: 396 10
-- Name: fn_delete_hipersen_outrossint(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_hipersen_outrossint() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.hipersen_outrossint
    where data.hipersen_outrossint.idhipersen_outrossint = old.idhipersen_outrossint;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_hipersen_outrossint() OWNER TO postgres;

--
-- TOC entry 39 (class 1255 OID 77581)
-- Dependencies: 396 10
-- Name: fn_delete_hipersen_reacaograve(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_hipersen_reacaograve() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.hipersen_reacaograve
    where data.hipersen_reacaograve.idhipersen_reacaograve = old.idhipersen_reacaograve;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_hipersen_reacaograve() OWNER TO postgres;

--
-- TOC entry 40 (class 1255 OID 77582)
-- Dependencies: 10 396
-- Name: fn_delete_hipersen_resultlab(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_hipersen_resultlab() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.hipersen_resultlab
    where data.hipersen_resultlab.idhipersen_resultlab = old.idhipersen_resultlab;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_hipersen_resultlab() OWNER TO postgres;

--
-- TOC entry 41 (class 1255 OID 77583)
-- Dependencies: 10 396
-- Name: fn_delete_hipersen_sinaisvitais(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_hipersen_sinaisvitais() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.hipersen_sinaisvitais
    where data.hipersen_sinaisvitais.idhipersen_sinaisvitais = old.idhipersen_sinaisvitais;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_hipersen_sinaisvitais() OWNER TO postgres;

--
-- TOC entry 42 (class 1255 OID 77584)
-- Dependencies: 10 396
-- Name: fn_delete_inclusaodados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_inclusaodados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.inclusao_dados
    where data.inclusao_dados.idinclusao_dados = old.idinclusao_dados;

    RETURN NULL;
    
END;
$$;


ALTER FUNCTION log.fn_delete_inclusaodados() OWNER TO postgres;

--
-- TOC entry 43 (class 1255 OID 77585)
-- Dependencies: 10 396
-- Name: fn_delete_inclusaodose(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_inclusaodose() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.inclusao_dose
    where data.inclusao_dose.idinclusao_dose = old.idinclusao_dose;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_inclusaodose() OWNER TO postgres;

--
-- TOC entry 44 (class 1255 OID 77586)
-- Dependencies: 396 10
-- Name: fn_delete_inclusaorand(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_inclusaorand() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.inclusao_rand
    where data.inclusao_rand.idinclusao_rand = old.idinclusao_rand;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_inclusaorand() OWNER TO postgres;

--
-- TOC entry 45 (class 1255 OID 77587)
-- Dependencies: 10 396
-- Name: fn_delete_microbacteriologiadados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_microbacteriologiadados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.microbacteriologia_dados
    where data.microbacteriologia_dados.idmicrobacteriologia_dados = old.idmicrobacteriologia_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_microbacteriologiadados() OWNER TO postgres;

--
-- TOC entry 46 (class 1255 OID 77588)
-- Dependencies: 10 396
-- Name: fn_delete_obito_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_obito_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.obito_dados
    where data.obito_dados.idobito_dados
     = old.idobito_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_obito_dados() OWNER TO postgres;

--
-- TOC entry 47 (class 1255 OID 77589)
-- Dependencies: 10 396
-- Name: fn_delete_re_introd_terapia_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_re_introd_terapia_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
 delete from data.re_introd_terapia_dados
 where data.re_introd_terapia_dados.idreintrod_terapia_dados
 = OLD.idreintrod_terapia_dados;

return null;

end;
$$;


ALTER FUNCTION log.fn_delete_re_introd_terapia_dados() OWNER TO postgres;

--
-- TOC entry 48 (class 1255 OID 77590)
-- Dependencies: 10 396
-- Name: fn_delete_resultadoslab(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_resultadoslab() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.resultados_lab_dados
    where data.resultados_lab_dados.idresultados_lab_dados = old.idresultados_lab_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_resultadoslab() OWNER TO postgres;

--
-- TOC entry 49 (class 1255 OID 77591)
-- Dependencies: 10 396
-- Name: fn_delete_term_estudo_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_term_estudo_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.term_estudo_dados
    where data.term_estudo_dados.idterm_estudo_dados
     = old.idterm_estudo_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_term_estudo_dados() OWNER TO postgres;

--
-- TOC entry 50 (class 1255 OID 77592)
-- Dependencies: 396 10
-- Name: fn_delete_visita_amostra(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_visita_amostra() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.visita_amostras
    where data.visita_amostras.idvisita_amostras = old.idvisita_amostras;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_visita_amostra() OWNER TO postgres;

--
-- TOC entry 51 (class 1255 OID 77593)
-- Dependencies: 396 10
-- Name: fn_delete_visita_dados(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_visita_dados() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.visita_dados
    where data.visita_dados.idvisita_dados = old.idvisita_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_visita_dados() OWNER TO postgres;

--
-- TOC entry 52 (class 1255 OID 77594)
-- Dependencies: 396 10
-- Name: fn_delete_visita_dot(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_visita_dot() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.visita_dot
    where data.visita_dot.idvisita_dot = old.idvisita_dot;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_visita_dot() OWNER TO postgres;

--
-- TOC entry 53 (class 1255 OID 77595)
-- Dependencies: 396 10
-- Name: fn_delete_visita_info_cli(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_visita_info_cli() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.visita_info_cli
    where data.visita_info_cli.idvisita_info_cli = old.idvisita_info_cli;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_visita_info_cli() OWNER TO postgres;

--
-- TOC entry 54 (class 1255 OID 77596)
-- Dependencies: 396 10
-- Name: fn_delete_visita_laboratorio(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_visita_laboratorio() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.visita_laboratorio
    where data.visita_laboratorio.idvisita_laboratorio = old.idvisita_laboratorio;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_visita_laboratorio() OWNER TO postgres;

--
-- TOC entry 55 (class 1255 OID 77597)
-- Dependencies: 10 396
-- Name: fn_delete_visita_sintomas(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_delete_visita_sintomas() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.visita_sintomas
    where data.visita_sintomas.idvisita_sintomas = old.idvisita_sintomas;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_delete_visita_sintomas() OWNER TO postgres;

--
-- TOC entry 56 (class 1255 OID 77598)
-- Dependencies: 396 10
-- Name: fn_deletehisdiagconc(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_deletehisdiagconc() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.historia_diag_conc
    where data.historia_diag_conc.idhistoria_diag_conc = old.idhistoria_diag_conc;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_deletehisdiagconc() OWNER TO postgres;

--
-- TOC entry 57 (class 1255 OID 77599)
-- Dependencies: 396 10
-- Name: fn_deletehistoriadiagconc(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_deletehistoriadiagconc() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.historia_diag_conc
    where data.historia_diag_conc.idhistoria_diag_conc = idhistoria_diag_conc;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_deletehistoriadiagconc() OWNER TO postgres;

--
-- TOC entry 58 (class 1255 OID 77600)
-- Dependencies: 10 396
-- Name: fn_deletehistoriadiagtb(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_deletehistoriadiagtb() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.historia_diag_tb
    where data.historia_diag_tb.idhistoria_diag_tb = old.idhistoria_diag_tb;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_deletehistoriadiagtb() OWNER TO postgres;

--
-- TOC entry 59 (class 1255 OID 77601)
-- Dependencies: 396 10
-- Name: fn_deletehistoriaexvisao(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_deletehistoriaexvisao() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.historia_ex_visao
    where data.historia_ex_visao.idhistoria_ex_visao = old.idhistoria_ex_visao;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_deletehistoriaexvisao() OWNER TO postgres;

--
-- TOC entry 60 (class 1255 OID 77602)
-- Dependencies: 10 396
-- Name: fn_deletehistoriafatorrisco(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_deletehistoriafatorrisco() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.historia_fator_risco
    where data.historia_fator_risco.idhistoria_fator_risco = old.idhistoria_fator_risco;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_deletehistoriafatorrisco() OWNER TO postgres;

--
-- TOC entry 61 (class 1255 OID 77603)
-- Dependencies: 396 10
-- Name: fn_deletehistoriainfocli(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_deletehistoriainfocli() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.historia_info_cli
    where data.historia_info_cli.idhistoria_info_cli = old.idhistoria_info_cli;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_deletehistoriainfocli() OWNER TO postgres;

--
-- TOC entry 62 (class 1255 OID 77604)
-- Dependencies: 10 396
-- Name: fn_deletehistoriaoutraav(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_deletehistoriaoutraav() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.historia_outra_av
    where data.historia_outra_av.idhistoria_outra_av = old.idhistoria_outra_av;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_deletehistoriaoutraav() OWNER TO postgres;

--
-- TOC entry 63 (class 1255 OID 77605)
-- Dependencies: 396 10
-- Name: fn_deletehistoriasintomas(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_deletehistoriasintomas() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.historia_sintomas
    where data.historia_sintomas.idhistoria_sintomas = old.idhistoria_sintomas;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_deletehistoriasintomas() OWNER TO postgres;

--
-- TOC entry 64 (class 1255 OID 77606)
-- Dependencies: 396 10
-- Name: fn_evento_adverso(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_evento_adverso() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.evento_adverso_dados
    where data.evento_adverso_dados.idevento_adverso_dados = old.idevento_adverso_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_evento_adverso() OWNER TO postgres;

--
-- TOC entry 65 (class 1255 OID 77607)
-- Dependencies: 10 396
-- Name: fn_falha_inclusao(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_falha_inclusao() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.falha_inclusao_dados
    where data.falha_inclusao_dados.idfalha_inclusao_dados = old.idfalha_inclusao_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_falha_inclusao() OWNER TO postgres;

--
-- TOC entry 66 (class 1255 OID 77608)
-- Dependencies: 10 396
-- Name: fn_teleradio_torax(); Type: FUNCTION; Schema: log; Owner: postgres
--

CREATE FUNCTION fn_teleradio_torax() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN

    delete from data.teleradio_torax_dados
    where data.teleradio_torax_dados.idtelerad_torax_dados = old.idteleradio_torax_dados;

    RETURN NULL;

END;
$$;


ALTER FUNCTION log.fn_teleradio_torax() OWNER TO postgres;

SET search_path = acesso, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = true;

--
-- TOC entry 1588 (class 1259 OID 77609)
-- Dependencies: 7
-- Name: permissao; Type: TABLE; Schema: acesso; Owner: positrot; Tablespace: 
--

CREATE TABLE permissao (
    idpermissao integer NOT NULL,
    tipo character varying NOT NULL
);


ALTER TABLE acesso.permissao OWNER TO positrot;

--
-- TOC entry 1589 (class 1259 OID 77615)
-- Dependencies: 1588 7
-- Name: permissao_idpermissao_seq; Type: SEQUENCE; Schema: acesso; Owner: positrot
--

CREATE SEQUENCE permissao_idpermissao_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE acesso.permissao_idpermissao_seq OWNER TO positrot;

--
-- TOC entry 1947 (class 0 OID 0)
-- Dependencies: 1589
-- Name: permissao_idpermissao_seq; Type: SEQUENCE OWNED BY; Schema: acesso; Owner: positrot
--

ALTER SEQUENCE permissao_idpermissao_seq OWNED BY permissao.idpermissao;


--
-- TOC entry 1948 (class 0 OID 0)
-- Dependencies: 1589
-- Name: permissao_idpermissao_seq; Type: SEQUENCE SET; Schema: acesso; Owner: positrot
--

SELECT pg_catalog.setval('permissao_idpermissao_seq', 3, true);


--
-- TOC entry 1590 (class 1259 OID 77617)
-- Dependencies: 7
-- Name: site; Type: TABLE; Schema: acesso; Owner: positrot; Tablespace: 
--

CREATE TABLE site (
    idsite integer NOT NULL,
    descricao character varying(15) NOT NULL,
    pidrangeinicio1 integer,
    pidrangefim1 integer,
    pidrangeinicio0 integer,
    pidrangefim0 integer,
    lograngeinicio integer,
    lograngefim integer,
    letrascreening character(1)
);


ALTER TABLE acesso.site OWNER TO positrot;

--
-- TOC entry 1591 (class 1259 OID 77620)
-- Dependencies: 1893 7
-- Name: tipousuario; Type: TABLE; Schema: acesso; Owner: positrot; Tablespace: 
--

CREATE TABLE tipousuario (
    idtipousuario integer DEFAULT nextval(('"acesso"."tipousuario_idtipousuario_seq"'::text)::regclass) NOT NULL,
    descricao character varying(30) NOT NULL
);


ALTER TABLE acesso.tipousuario OWNER TO positrot;

--
-- TOC entry 1592 (class 1259 OID 77624)
-- Dependencies: 7
-- Name: tipousuario_idtipousuario_seq; Type: SEQUENCE; Schema: acesso; Owner: positrot
--

CREATE SEQUENCE tipousuario_idtipousuario_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2147483647
    CACHE 1;


ALTER TABLE acesso.tipousuario_idtipousuario_seq OWNER TO positrot;

--
-- TOC entry 1949 (class 0 OID 0)
-- Dependencies: 1592
-- Name: tipousuario_idtipousuario_seq; Type: SEQUENCE SET; Schema: acesso; Owner: positrot
--

SELECT pg_catalog.setval('tipousuario_idtipousuario_seq', 3, true);


SET default_with_oids = false;

--
-- TOC entry 1593 (class 1259 OID 77626)
-- Dependencies: 1894 1895 1896 7
-- Name: usuario; Type: TABLE; Schema: acesso; Owner: positrot; Tablespace: 
--

CREATE TABLE usuario (
    idusuario integer DEFAULT nextval(('"acesso"."usuario_idusuario_seq"'::text)::regclass) NOT NULL,
    login character varying(14) NOT NULL,
    senha text NOT NULL,
    tipo integer NOT NULL,
    nome character varying(60) NOT NULL,
    sexo character(1) NOT NULL,
    endereco character varying(60),
    bairro character varying(30),
    cidade character varying(30),
    estado character(2),
    cep character(8),
    telfixo character varying(15),
    telcel character varying(15),
    email character varying(50),
    ativo boolean NOT NULL,
    senha_expirada boolean DEFAULT false NOT NULL,
    site integer NOT NULL,
    tipoacesso integer NOT NULL,
    versites boolean DEFAULT false NOT NULL
);


ALTER TABLE acesso.usuario OWNER TO positrot;

--
-- TOC entry 1594 (class 1259 OID 77635)
-- Dependencies: 7
-- Name: usuario_idusuario_seq; Type: SEQUENCE; Schema: acesso; Owner: positrot
--

CREATE SEQUENCE usuario_idusuario_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2147483647
    CACHE 1;


ALTER TABLE acesso.usuario_idusuario_seq OWNER TO positrot;

--
-- TOC entry 1950 (class 0 OID 0)
-- Dependencies: 1594
-- Name: usuario_idusuario_seq; Type: SEQUENCE SET; Schema: acesso; Owner: positrot
--

SELECT pg_catalog.setval('usuario_idusuario_seq', 1, true);


SET search_path = adm, pg_catalog;

--
-- TOC entry 1595 (class 1259 OID 77637)
-- Dependencies: 1696 8
-- Name: v_sequences; Type: VIEW; Schema: adm; Owner: postgres
--

CREATE VIEW v_sequences AS
    SELECT n.nspname AS schema_name, pg_get_userbyid(c.relowner) AS owner, c.relname AS sequence_name FROM pg_class c, pg_namespace n WHERE (((c.relkind = 'S'::"char") AND (n.oid = c.relnamespace)) AND (((n.nspname <> 'pg_catalog'::name) AND (n.nspname <> 'pg_toast'::name)) AND (n.nspname <> 'information_schema'::name))) ORDER BY n.nspname, c.relname;


ALTER TABLE adm.v_sequences OWNER TO postgres;

--
-- TOC entry 1596 (class 1259 OID 77641)
-- Dependencies: 1697 8
-- Name: v_serial_sequences; Type: VIEW; Schema: adm; Owner: postgres
--

CREATE VIEW v_serial_sequences AS
    SELECT pn_seq.nspname AS schema, pg_get_userbyid(seq.relowner) AS sequence_owner, seq.relname AS sequence_name, pg_get_userbyid(pc.relowner) AS table_owner, pc.relname AS table_name, pa.attname AS column_name, (((((((((((('


    SELECT setval('::text || chr(39)) || (pn_seq.nspname)::text) || '.'::text) || (seq.relname)::text) || chr(39)) || ', max('::text) || (pa.attname)::text) || '))
FROM
    '::text) || (pn_seq.nspname)::text) || '.'::text) || (pc.relname)::text) || ';'::text) AS sql_update, ((((((('


    SELECT setval('::text || chr(39)) || (pn_seq.nspname)::text) || '.'::text) || (seq.relname)::text) || chr(39)) || ', 1, true ) '::text) || ';'::text) AS sql_reinitialize FROM pg_namespace pn, pg_class pc, pg_attribute pa, pg_depend pd, pg_class seq, pg_namespace pn_seq WHERE ((((((((((pn.oid = pc.relnamespace) AND (pc.oid = pa.attrelid)) AND (pd.objid = seq.oid)) AND (pd.classid = seq.tableoid)) AND (pd.refclassid = seq.tableoid)) AND (pd.refobjid = pc.oid)) AND (pd.refobjsubid = pa.attnum)) AND (pd.deptype = 'i'::"char")) AND (seq.relkind = 'S'::"char")) AND (seq.relnamespace = pn_seq.oid)) ORDER BY pn_seq.nspname;


ALTER TABLE adm.v_serial_sequences OWNER TO postgres;

SET search_path = data, pg_catalog;

--
-- TOC entry 1608 (class 1259 OID 77881)
-- Dependencies: 1902 1903 9
-- Name: elegibilidade; Type: TABLE; Schema: data; Owner: positrot; Tablespace: 
--

CREATE TABLE elegibilidade (
    idelegibilidade integer NOT NULL,
    digitacao integer NOT NULL,
    auditado boolean NOT NULL,
    digitador integer NOT NULL,
    idelegibilidade_dados integer NOT NULL,
    dtinclusao date DEFAULT now() NOT NULL,
    site integer,
    CONSTRAINT elegibilidade_digitacao_chk CHECK (((digitacao >= 0) OR (digitacao <= 3)))
);


ALTER TABLE data.elegibilidade OWNER TO positrot;

SET default_with_oids = true;

--
-- TOC entry 1606 (class 1259 OID 77850)
-- Dependencies: 9
-- Name: elegibilidade_dados; Type: TABLE; Schema: data; Owner: positrot; Tablespace: 
--

CREATE TABLE elegibilidade_dados (
    idelegibilidade_dados integer NOT NULL,
    unidade integer,
    nome character varying(255),
    dtnascimento integer,
    num_prontuario integer,
    num_alternativo integer,
    sexo integer,
    tb_passado integer,
    quimio_passado integer,
    pac_particular integer,
    rec_termo integer,
    dtcomparecimento integer,
    dtult_ppd integer,
    resultado_ppdmm character varying,
    resultado_ppd integer,
    dtinclusao integer,
    numestudo integer,
    enfermeira character varying(255)
);


ALTER TABLE data.elegibilidade_dados OWNER TO positrot;

--
-- TOC entry 1605 (class 1259 OID 77848)
-- Dependencies: 1606 9
-- Name: elegibilidade_dados_idelegibilidade_dados_seq; Type: SEQUENCE; Schema: data; Owner: positrot
--

CREATE SEQUENCE elegibilidade_dados_idelegibilidade_dados_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.elegibilidade_dados_idelegibilidade_dados_seq OWNER TO positrot;

--
-- TOC entry 1951 (class 0 OID 0)
-- Dependencies: 1605
-- Name: elegibilidade_dados_idelegibilidade_dados_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: positrot
--

ALTER SEQUENCE elegibilidade_dados_idelegibilidade_dados_seq OWNED BY elegibilidade_dados.idelegibilidade_dados;


--
-- TOC entry 1952 (class 0 OID 0)
-- Dependencies: 1605
-- Name: elegibilidade_dados_idelegibilidade_dados_seq; Type: SEQUENCE SET; Schema: data; Owner: positrot
--

SELECT pg_catalog.setval('elegibilidade_dados_idelegibilidade_dados_seq', 30, true);


--
-- TOC entry 1607 (class 1259 OID 77879)
-- Dependencies: 9 1608
-- Name: elegibilidade_idelegibilidade_seq; Type: SEQUENCE; Schema: data; Owner: positrot
--

CREATE SEQUENCE elegibilidade_idelegibilidade_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE data.elegibilidade_idelegibilidade_seq OWNER TO positrot;

--
-- TOC entry 1953 (class 0 OID 0)
-- Dependencies: 1607
-- Name: elegibilidade_idelegibilidade_seq; Type: SEQUENCE OWNED BY; Schema: data; Owner: positrot
--

ALTER SEQUENCE elegibilidade_idelegibilidade_seq OWNED BY elegibilidade.idelegibilidade;


--
-- TOC entry 1954 (class 0 OID 0)
-- Dependencies: 1607
-- Name: elegibilidade_idelegibilidade_seq; Type: SEQUENCE SET; Schema: data; Owner: positrot
--

SELECT pg_catalog.setval('elegibilidade_idelegibilidade_seq', 30, true);


--
-- TOC entry 1609 (class 1259 OID 77908)
-- Dependencies: 1700 9
-- Name: vw_elegibilidade_resumo; Type: VIEW; Schema: data; Owner: positrot
--

CREATE VIEW vw_elegibilidade_resumo AS
    SELECT e.idelegibilidade, e.site, ed.numestudo, e.dtinclusao FROM elegibilidade e, elegibilidade_dados ed WHERE (((e.idelegibilidade_dados = ed.idelegibilidade_dados) AND (e.auditado = true)) AND ((e.digitacao = 0) OR (e.digitacao = 3))) ORDER BY ed.numestudo;


ALTER TABLE data.vw_elegibilidade_resumo OWNER TO positrot;

SET search_path = log, pg_catalog;

--
-- TOC entry 1597 (class 1259 OID 77646)
-- Dependencies: 10
-- Name: acao; Type: TABLE; Schema: log; Owner: positrot; Tablespace: 
--

CREATE TABLE acao (
    idacao integer NOT NULL,
    descricao character varying NOT NULL
);


ALTER TABLE log.acao OWNER TO positrot;

--
-- TOC entry 1598 (class 1259 OID 77652)
-- Dependencies: 10 1597
-- Name: acao_idacao_seq; Type: SEQUENCE; Schema: log; Owner: positrot
--

CREATE SEQUENCE acao_idacao_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE log.acao_idacao_seq OWNER TO positrot;

--
-- TOC entry 1955 (class 0 OID 0)
-- Dependencies: 1598
-- Name: acao_idacao_seq; Type: SEQUENCE OWNED BY; Schema: log; Owner: positrot
--

ALTER SEQUENCE acao_idacao_seq OWNED BY acao.idacao;


--
-- TOC entry 1956 (class 0 OID 0)
-- Dependencies: 1598
-- Name: acao_idacao_seq; Type: SEQUENCE SET; Schema: log; Owner: positrot
--

SELECT pg_catalog.setval('acao_idacao_seq', 15, true);


--
-- TOC entry 1599 (class 1259 OID 77654)
-- Dependencies: 10
-- Name: form; Type: TABLE; Schema: log; Owner: positrot; Tablespace: 
--

CREATE TABLE form (
    idform integer NOT NULL,
    nome character varying NOT NULL
);


ALTER TABLE log.form OWNER TO positrot;

--
-- TOC entry 1600 (class 1259 OID 77660)
-- Dependencies: 1599 10
-- Name: form_idform_seq; Type: SEQUENCE; Schema: log; Owner: positrot
--

CREATE SEQUENCE form_idform_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE log.form_idform_seq OWNER TO positrot;

--
-- TOC entry 1957 (class 0 OID 0)
-- Dependencies: 1600
-- Name: form_idform_seq; Type: SEQUENCE OWNED BY; Schema: log; Owner: positrot
--

ALTER SEQUENCE form_idform_seq OWNED BY form.idform;


--
-- TOC entry 1958 (class 0 OID 0)
-- Dependencies: 1600
-- Name: form_idform_seq; Type: SEQUENCE SET; Schema: log; Owner: positrot
--

SELECT pg_catalog.setval('form_idform_seq', 1, false);


--
-- TOC entry 1601 (class 1259 OID 77662)
-- Dependencies: 10
-- Name: log; Type: TABLE; Schema: log; Owner: positrot; Tablespace: 
--

CREATE TABLE log (
    idlog integer NOT NULL,
    ip character varying(15) NOT NULL,
    idusuario integer,
    dtinclusao integer NOT NULL,
    hrinclusao character varying(8) NOT NULL,
    idacao integer,
    pid integer NOT NULL,
    idform integer,
    obs character varying,
    numscreening character varying(5)
);


ALTER TABLE log.log OWNER TO positrot;

--
-- TOC entry 1602 (class 1259 OID 77668)
-- Dependencies: 10 1601
-- Name: log_idlog_seq; Type: SEQUENCE; Schema: log; Owner: positrot
--

CREATE SEQUENCE log_idlog_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE log.log_idlog_seq OWNER TO positrot;

--
-- TOC entry 1959 (class 0 OID 0)
-- Dependencies: 1602
-- Name: log_idlog_seq; Type: SEQUENCE OWNED BY; Schema: log; Owner: positrot
--

ALTER SEQUENCE log_idlog_seq OWNED BY log.idlog;


--
-- TOC entry 1960 (class 0 OID 0)
-- Dependencies: 1602
-- Name: log_idlog_seq; Type: SEQUENCE SET; Schema: log; Owner: positrot
--

SELECT pg_catalog.setval('log_idlog_seq', 119, true);


--
-- TOC entry 1603 (class 1259 OID 77670)
-- Dependencies: 1698 10
-- Name: vw_acessosremotos; Type: VIEW; Schema: log; Owner: positrot
--

CREATE VIEW vw_acessosremotos AS
    SELECT log.idlog, log.ip, log.idusuario, log.dtinclusao, log.hrinclusao, log.idacao, log.pid, log.idform, log.obs FROM log WHERE (((((log.ip)::text <> '<IP>'::text) OR ((log.ip)::text <> '192.168.1.12'::text)) OR ((log.ip)::text <> '127.0.0.1'::text)) OR ((log.ip)::text <> '192.168.1.1'::text)) ORDER BY log.idlog DESC;


ALTER TABLE log.vw_acessosremotos OWNER TO positrot;

--
-- TOC entry 1604 (class 1259 OID 77674)
-- Dependencies: 1699 10
-- Name: vw_eventoslog; Type: VIEW; Schema: log; Owner: positrot
--

CREATE VIEW vw_eventoslog AS
    SELECT l.idlog, l.ip, u.login AS usuario, l.dtinclusao, l.hrinclusao, a.descricao AS acao, f.nome AS form, l.pid, l.numscreening, l.obs FROM (log l LEFT JOIN acesso.usuario u ON ((u.idusuario = l.idusuario))), acao a, form f WHERE ((l.idacao = a.idacao) AND (l.idform = f.idform)) ORDER BY l.idlog DESC;


ALTER TABLE log.vw_eventoslog OWNER TO positrot;

SET search_path = acesso, pg_catalog;

--
-- TOC entry 1892 (class 2604 OID 77679)
-- Dependencies: 1589 1588
-- Name: idpermissao; Type: DEFAULT; Schema: acesso; Owner: positrot
--

ALTER TABLE permissao ALTER COLUMN idpermissao SET DEFAULT nextval('permissao_idpermissao_seq'::regclass);


SET search_path = data, pg_catalog;

--
-- TOC entry 1901 (class 2604 OID 77884)
-- Dependencies: 1607 1608 1608
-- Name: idelegibilidade; Type: DEFAULT; Schema: data; Owner: positrot
--

ALTER TABLE elegibilidade ALTER COLUMN idelegibilidade SET DEFAULT nextval('elegibilidade_idelegibilidade_seq'::regclass);


--
-- TOC entry 1900 (class 2604 OID 77853)
-- Dependencies: 1605 1606 1606
-- Name: idelegibilidade_dados; Type: DEFAULT; Schema: data; Owner: positrot
--

ALTER TABLE elegibilidade_dados ALTER COLUMN idelegibilidade_dados SET DEFAULT nextval('elegibilidade_dados_idelegibilidade_dados_seq'::regclass);


SET search_path = log, pg_catalog;

--
-- TOC entry 1897 (class 2604 OID 77680)
-- Dependencies: 1598 1597
-- Name: idacao; Type: DEFAULT; Schema: log; Owner: positrot
--

ALTER TABLE acao ALTER COLUMN idacao SET DEFAULT nextval('acao_idacao_seq'::regclass);


--
-- TOC entry 1898 (class 2604 OID 77681)
-- Dependencies: 1600 1599
-- Name: idform; Type: DEFAULT; Schema: log; Owner: positrot
--

ALTER TABLE form ALTER COLUMN idform SET DEFAULT nextval('form_idform_seq'::regclass);


--
-- TOC entry 1899 (class 2604 OID 77682)
-- Dependencies: 1602 1601
-- Name: idlog; Type: DEFAULT; Schema: log; Owner: positrot
--

ALTER TABLE log ALTER COLUMN idlog SET DEFAULT nextval('log_idlog_seq'::regclass);


SET search_path = acesso, pg_catalog;

--
-- TOC entry 1933 (class 0 OID 77609)
-- Dependencies: 1588
-- Data for Name: permissao; Type: TABLE DATA; Schema: acesso; Owner: positrot
--

INSERT INTO permissao VALUES (1, 'CADASTRO');
INSERT INTO permissao VALUES (2, 'LEITURA');
INSERT INTO permissao VALUES (3, 'ALTERAÇÃO');


--
-- TOC entry 1934 (class 0 OID 77617)
-- Dependencies: 1590
-- Data for Name: site; Type: TABLE DATA; Schema: acesso; Owner: positrot
--

INSERT INTO site VALUES (6, '13 DE MAIO', 310001, 320000, 310000, 320000, NULL, NULL, NULL);
INSERT INTO site VALUES (7, 'COPACABANA', 320001, 330000, 320001, 330000, NULL, NULL, NULL);
INSERT INTO site VALUES (23, 'MADUREIRA', 330001, 340000, 330001, 340000, NULL, NULL, NULL);
INSERT INTO site VALUES (29, 'SANTA CRUZ', 340001, 350000, 340001, 350000, NULL, NULL, NULL);


--
-- TOC entry 1935 (class 0 OID 77620)
-- Dependencies: 1591
-- Data for Name: tipousuario; Type: TABLE DATA; Schema: acesso; Owner: positrot
--

INSERT INTO tipousuario VALUES (1, 'DIGITADOR');
INSERT INTO tipousuario VALUES (2, 'ADMINISTRADOR');
INSERT INTO tipousuario VALUES (3, 'USUARIO');


--
-- TOC entry 1936 (class 0 OID 77626)
-- Dependencies: 1593
-- Data for Name: usuario; Type: TABLE DATA; Schema: acesso; Owner: positrot
--

INSERT INTO usuario VALUES (2, 'DIG1', 'fa1da845f92fb80ea70981ca94554c70f236ba81', 2, 'DIGITADOR 1', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'marceloczeferino@gmail.com', true, false, 6, 3, true);
INSERT INTO usuario VALUES (3, 'DIG2', '89021ebae3d3ed835e1080a4c3c24c761e380d63', 2, 'DIGITADOR 2', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'marceloczeferino@gmail.com', true, false, 6, 3, true);
INSERT INTO usuario VALUES (1, 'ADMIN', 'd033e22ae348aeb5660fc2140aec35850c4da997', 2, 'ADMIN', ' ', '', '', '', '  ', '        ', '', '', 'marceloczeferino@gmail.com', true, false, 6, 3, true);
INSERT INTO usuario VALUES (999, 'TESTE', '53da484281e20b802c8752e8c38e2ed6c0a4131b', 2, 'TESTE', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'teste@gmail.com', true, true, 6, 3, true);


SET search_path = data, pg_catalog;

--
-- TOC entry 1941 (class 0 OID 77881)
-- Dependencies: 1608
-- Data for Name: elegibilidade; Type: TABLE DATA; Schema: data; Owner: positrot
--



--
-- TOC entry 1940 (class 0 OID 77850)
-- Dependencies: 1606
-- Data for Name: elegibilidade_dados; Type: TABLE DATA; Schema: data; Owner: positrot
--



SET search_path = log, pg_catalog;

--
-- TOC entry 1937 (class 0 OID 77646)
-- Dependencies: 1597
-- Data for Name: acao; Type: TABLE DATA; Schema: log; Owner: positrot
--

INSERT INTO acao VALUES (1, 'LOGIN');
INSERT INTO acao VALUES (2, 'LOGOUT');
INSERT INTO acao VALUES (4, 'SEGUNDA DIGITACAO');
INSERT INTO acao VALUES (5, 'AUDITORIA AUTOMATICA');
INSERT INTO acao VALUES (6, 'DIVERGENCIA ENTRE DIGITACOES');
INSERT INTO acao VALUES (7, 'AUDITORIA MANUAL');
INSERT INTO acao VALUES (8, 'EXCLUSAO AUDITORIA');
INSERT INTO acao VALUES (9, 'EXCLUSAO CONSULTA');
INSERT INTO acao VALUES (10, 'FALHA LOGIN');
INSERT INTO acao VALUES (11, 'ALTERACAO DE SENHA');
INSERT INTO acao VALUES (12, 'CADASTRO');
INSERT INTO acao VALUES (13, 'ALTERACAO DE FORMULARIO');
INSERT INTO acao VALUES (14, 'ALTERACAO');
INSERT INTO acao VALUES (15, 'EXCLUSAO DE ORFAO');
INSERT INTO acao VALUES (3, 'PRIMEIRA DIGITACAO');


--
-- TOC entry 1938 (class 0 OID 77654)
-- Dependencies: 1599
-- Data for Name: form; Type: TABLE DATA; Schema: log; Owner: positrot
--

INSERT INTO form VALUES (0, 'NA');
INSERT INTO form VALUES (1, 'ELEGIBILIDADE');


--
-- TOC entry 1939 (class 0 OID 77662)
-- Dependencies: 1601
-- Data for Name: log; Type: TABLE DATA; Schema: log; Owner: positrot
--

INSERT INTO log VALUES (1, '0:0:0:0:0:0:0:1', 1, 20120205, '03:34:36', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (2, '0:0:0:0:0:0:0:1', 1, 20120205, '03:59:55', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (3, '0:0:0:0:0:0:0:1', 1, 20120205, '04:00:22', 14, 9999, 0, 'USUARIO: ADMIN', NULL);
INSERT INTO log VALUES (4, '0:0:0:0:0:0:0:1', 1, 20120205, '04:00:43', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (5, '0:0:0:0:0:0:0:1', 1, 20120205, '04:01:09', 11, 9999, 0, '', NULL);
INSERT INTO log VALUES (6, '0:0:0:0:0:0:0:1', 1, 20120205, '04:01:09', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (7, '0:0:0:0:0:0:0:1', NULL, 20120222, '00:59:27', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (8, '0:0:0:0:0:0:0:1', NULL, 20120222, '00:59:33', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (9, '0:0:0:0:0:0:0:1', NULL, 20120222, '00:59:54', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (10, '0:0:0:0:0:0:0:1', NULL, 20120222, '00:59:58', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (11, '0:0:0:0:0:0:0:1', NULL, 20120222, '01:00:51', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (12, '0:0:0:0:0:0:0:1', NULL, 20120222, '01:01:05', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (13, '0:0:0:0:0:0:0:1', NULL, 20120222, '01:01:51', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (14, '0:0:0:0:0:0:0:1', 1, 20120222, '01:01:54', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (15, '192.168.1.1', 999, 20120226, '00:00:37', 1, 1234, 0, NULL, NULL);
INSERT INTO log VALUES (16, '192.168.1.1', 999, 20120226, '00:00:37', 1, 9999, 0, NULL, NULL);
INSERT INTO log VALUES (17, '<IP>', 999, 20120226, '02:12:21', 3, 310939, 1, '', NULL);
INSERT INTO log VALUES (18, '<IP>', 999, 20120226, '02:16:33', 3, 310133, 1, '', NULL);
INSERT INTO log VALUES (19, '<IP>', 999, 20120226, '02:28:16', 3, 310846, 1, '', NULL);
INSERT INTO log VALUES (20, '<IP>', 999, 20120226, '02:28:39', 3, 310170, 1, '', NULL);
INSERT INTO log VALUES (21, '<IP>', 999, 20120226, '02:29:18', 3, 310715, 1, '', NULL);
INSERT INTO log VALUES (22, '<IP>', 999, 20120226, '02:31:26', 3, 310997, 1, '', NULL);
INSERT INTO log VALUES (23, '<IP>', 999, 20120226, '02:32:39', 3, 310374, 1, '', NULL);
INSERT INTO log VALUES (24, '<IP>', 999, 20120226, '02:36:21', 3, 310444, 1, '', NULL);
INSERT INTO log VALUES (25, '<IP>', 999, 20120226, '02:37:37', 4, 310444, 1, '', NULL);
INSERT INTO log VALUES (26, '<IP>', 999, 20120226, '02:38:36', 5, 310444, 1, '', NULL);
INSERT INTO log VALUES (27, '<IP>', 999, 20120226, '03:01:16', 3, 310812, 1, '', NULL);
INSERT INTO log VALUES (28, '<IP>', 999, 20120226, '03:01:57', 4, 310812, 1, '', NULL);
INSERT INTO log VALUES (29, '<IP>', 999, 20120226, '03:02:01', 5, 310812, 1, '', NULL);
INSERT INTO log VALUES (30, '<IP>', 999, 20120226, '03:02:18', 3, 310823, 1, '', NULL);
INSERT INTO log VALUES (31, '<IP>', 999, 20120226, '03:12:28', 3, 310678, 1, '', NULL);
INSERT INTO log VALUES (32, '<IP>', 999, 20120226, '03:12:28', 4, 310678, 1, '', NULL);
INSERT INTO log VALUES (33, '<IP>', 999, 20120226, '03:12:28', 5, 310678, 1, '', NULL);
INSERT INTO log VALUES (34, '<IP>', 999, 20120226, '03:14:41', 3, 310635, 1, '', NULL);
INSERT INTO log VALUES (35, '<IP>', 999, 20120226, '03:14:41', 4, 310635, 1, '', NULL);
INSERT INTO log VALUES (36, '<IP>', 999, 20120226, '03:14:41', 5, 310635, 1, '', NULL);
INSERT INTO log VALUES (37, '<IP>', 999, 20120226, '03:14:41', 3, 310911, 1, '', NULL);
INSERT INTO log VALUES (38, '<IP>', 999, 20120226, '03:14:41', 4, 310911, 1, '', NULL);
INSERT INTO log VALUES (39, '<IP>', 999, 20120226, '03:14:41', 5, 310911, 1, ' - ERRO: Can''t find bundle for base name br.com.positrot.view.resource.elegibilidade.ElegibilidadeDados, locale pt_BR', NULL);
INSERT INTO log VALUES (40, '<IP>', 999, 20120226, '03:24:46', 3, 310400, 1, '', NULL);
INSERT INTO log VALUES (41, '<IP>', 999, 20120226, '03:24:47', 4, 310400, 1, '', NULL);
INSERT INTO log VALUES (42, '<IP>', 999, 20120226, '03:24:47', 6, 310400, 1, 'QUESTÕES: ENFERMEIRA, NOME, QUIMIONOPASSADO, SEXO', NULL);
INSERT INTO log VALUES (43, '<IP>', 999, 20120226, '03:26:51', 3, 310579, 1, '', NULL);
INSERT INTO log VALUES (44, '<IP>', 999, 20120226, '03:26:51', 4, 310579, 1, '', NULL);
INSERT INTO log VALUES (45, '<IP>', 999, 20120226, '03:26:51', 5, 310579, 1, '', NULL);
INSERT INTO log VALUES (46, '<IP>', 999, 20120226, '03:26:51', 13, 310579, 1, 'VALORES ANTERIORES: ENFERMEIRA = FULANA, NOME = PACIENTE 1, SEXO = 1', NULL);
INSERT INTO log VALUES (47, '<IP>', 999, 20120226, '03:26:51', 3, 310953, 1, '', NULL);
INSERT INTO log VALUES (48, '<IP>', 999, 20120226, '03:26:51', 4, 310953, 1, '', NULL);
INSERT INTO log VALUES (49, '<IP>', 999, 20120226, '03:26:51', 6, 310953, 1, 'QUESTÕES: ENFERMEIRA, NOME, QUIMIONOPASSADO, SEXO', NULL);
INSERT INTO log VALUES (50, '0:0:0:0:0:0:0:1', NULL, 20120226, '03:45:51', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (51, '0:0:0:0:0:0:0:1', 1, 20120226, '03:46:25', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (52, '0:0:0:0:0:0:0:1', 1, 20120226, '03:46:39', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (53, '0:0:0:0:0:0:0:1', 1, 20120226, '03:46:48', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (54, '0:0:0:0:0:0:0:1', 1, 20120226, '03:47:16', 12, 9999, 0, 'USUARIO: DIG1ERRO: could not insert: [br.com.positrot.model.vo.UsuarioVO]', NULL);
INSERT INTO log VALUES (55, '0:0:0:0:0:0:0:1', 1, 20120226, '03:48:15', 12, 9999, 0, 'USUARIO: DIG1ERRO: could not insert: [br.com.positrot.model.vo.UsuarioVO]', NULL);
INSERT INTO log VALUES (56, '0:0:0:0:0:0:0:1', 1, 20120226, '03:49:41', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (57, '0:0:0:0:0:0:0:1', 1, 20120226, '03:55:35', 12, 9999, 0, 'USUARIO: DIG1ERRO: could not insert: [br.com.positrot.model.vo.UsuarioVO]', NULL);
INSERT INTO log VALUES (58, '0:0:0:0:0:0:0:1', 1, 20120226, '04:00:18', 12, 9999, 0, 'USUARIO: DIG1ERRO: could not insert: [br.com.positrot.model.vo.UsuarioVO]', NULL);
INSERT INTO log VALUES (59, '0:0:0:0:0:0:0:1', 1, 20120226, '04:00:32', 12, 9999, 0, 'USUARIO: DIGERRO: could not insert: [br.com.positrot.model.vo.UsuarioVO]', NULL);
INSERT INTO log VALUES (60, '0:0:0:0:0:0:0:1', 1, 20120226, '04:09:06', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (61, '0:0:0:0:0:0:0:1', 1, 20120226, '04:09:09', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (62, '0:0:0:0:0:0:0:1', 2, 20120226, '04:09:19', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (63, '0:0:0:0:0:0:0:1', 2, 20120226, '04:16:01', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (64, '0:0:0:0:0:0:0:1', 2, 20120226, '04:23:52', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (65, '0:0:0:0:0:0:0:1', 2, 20120226, '04:27:08', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (66, '0:0:0:0:0:0:0:1', 2, 20120226, '04:40:43', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (67, '0:0:0:0:0:0:0:1', 2, 20120226, '04:58:27', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (68, '0:0:0:0:0:0:0:1', 2, 20120227, '23:13:34', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (69, '0:0:0:0:0:0:0:1', 2, 20120227, '23:23:22', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (70, '0:0:0:0:0:0:0:1', 2, 20120227, '23:42:40', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (71, '0:0:0:0:0:0:0:1', 2, 20120227, '23:48:14', 3, 310001, 1, '', NULL);
INSERT INTO log VALUES (72, '0:0:0:0:0:0:0:1', 2, 20120228, '00:00:21', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (73, '0:0:0:0:0:0:0:1', 2, 20120228, '00:03:30', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (74, '0:0:0:0:0:0:0:1', 2, 20120228, '00:09:49', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (75, '0:0:0:0:0:0:0:1', 2, 20120228, '00:15:45', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (76, '0:0:0:0:0:0:0:1', 2, 20120228, '00:16:43', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (77, '0:0:0:0:0:0:0:1', 2, 20120228, '00:18:25', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (78, '0:0:0:0:0:0:0:1', 2, 20120228, '00:20:47', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (79, '0:0:0:0:0:0:0:1', 2, 20120228, '00:26:26', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (80, '0:0:0:0:0:0:0:1', 2, 20120228, '00:28:33', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (81, '0:0:0:0:0:0:0:1', 2, 20120228, '00:29:52', 4, 310001, 1, '', NULL);
INSERT INTO log VALUES (82, '0:0:0:0:0:0:0:1', 2, 20120228, '00:29:52', 6, 310001, 1, 'QUESTÕES: 3, 6, 8, 9, 11, 13, 14, 17', NULL);
INSERT INTO log VALUES (83, '0:0:0:0:0:0:0:1', 2, 20120228, '00:30:05', 2, 9999, 0, 'LOGOUT - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (84, '0:0:0:0:0:0:0:1', 1, 20120228, '00:30:18', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (85, '0:0:0:0:0:0:0:1', 2, 20120228, '00:39:27', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (86, '0:0:0:0:0:0:0:1', 2, 20120228, '00:39:32', 2, 9999, 0, 'LOGOUT - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (87, '0:0:0:0:0:0:0:1', 1, 20120228, '00:39:42', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (88, '0:0:0:0:0:0:0:1', 1, 20120228, '00:43:56', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (89, '0:0:0:0:0:0:0:1', NULL, 20120228, '00:44:45', 10, 9999, 0, 'TENTATIVA DE ACESSO COM SENHA INVÁLIDA. - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (90, '0:0:0:0:0:0:0:1', 1, 20120228, '00:44:49', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (91, '0:0:0:0:0:0:0:1', 1, 20120228, '01:01:58', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (92, '0:0:0:0:0:0:0:1', 1, 20120228, '01:06:16', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (93, '0:0:0:0:0:0:0:1', 1, 20120228, '01:16:15', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (94, '0:0:0:0:0:0:0:1', 1, 20120228, '01:16:55', 9, 310444, 1, '', NULL);
INSERT INTO log VALUES (95, '0:0:0:0:0:0:0:1', 1, 20120228, '01:21:40', 13, 310579, 1, 'VALORES ANTERIORES: 2 = FULANO DA SILVA, 3 = 31/10/1983, 6 = 2, 10 = 0, 13 = 01, 14 = 1', NULL);
INSERT INTO log VALUES (96, '0:0:0:0:0:0:0:1', 1, 20120228, '01:57:50', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (97, '0:0:0:0:0:0:0:1', 1, 20120228, '01:59:51', 8, 310001, 1, '', NULL);
INSERT INTO log VALUES (98, '0:0:0:0:0:0:0:1', 1, 20120228, '02:00:00', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (99, '0:0:0:0:0:0:0:1', 2, 20120228, '02:00:03', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (100, '0:0:0:0:0:0:0:1', 2, 20120228, '02:00:45', 3, 320000, 1, '', NULL);
INSERT INTO log VALUES (101, '0:0:0:0:0:0:0:1', 2, 20120228, '02:02:27', 4, 320000, 1, '', NULL);
INSERT INTO log VALUES (102, '0:0:0:0:0:0:0:1', 2, 20120228, '02:02:27', 6, 320000, 1, 'QUESTÕES: 4, 9, 10, 12, 13, 15, 17', NULL);
INSERT INTO log VALUES (103, '0:0:0:0:0:0:0:1', 2, 20120228, '02:02:31', 2, 9999, 0, 'LOGOUT - LOGIN: DIG1', NULL);
INSERT INTO log VALUES (104, '0:0:0:0:0:0:0:1', 1, 20120228, '02:02:34', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (105, '0:0:0:0:0:0:0:1', 1, 20120228, '02:03:36', 7, 320000, 1, '', NULL);
INSERT INTO log VALUES (106, '0:0:0:0:0:0:0:1', 1, 20120228, '02:04:15', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (107, '0:0:0:0:0:0:0:1', 1, 20120228, '02:11:25', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (108, '0:0:0:0:0:0:0:1', 1, 20120228, '02:11:38', 14, 9999, 0, 'USUARIO: ADMIN', NULL);
INSERT INTO log VALUES (109, '0:0:0:0:0:0:0:1', 1, 20120228, '02:12:12', 14, 9999, 0, 'USUARIO: ADMIN', NULL);
INSERT INTO log VALUES (110, '0:0:0:0:0:0:0:1', 1, 20120228, '02:12:31', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (111, '0:0:0:0:0:0:0:1', 1, 20120228, '02:12:32', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (112, '0:0:0:0:0:0:0:1', 1, 20120228, '02:13:40', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (113, '0:0:0:0:0:0:0:1', 1, 20120228, '02:13:41', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (114, '0:0:0:0:0:0:0:1', 1, 20120228, '02:14:19', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (115, '0:0:0:0:0:0:0:1', 1, 20120228, '02:14:20', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (116, '0:0:0:0:0:0:0:1', 1, 20120228, '02:16:24', 2, 9999, 0, 'LOGOUT - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (117, '0:0:0:0:0:0:0:1', 1, 20120228, '02:16:25', 1, 9999, 0, 'ACESSO AO SISTEMA - LOGIN: ADMIN', NULL);
INSERT INTO log VALUES (118, '0:0:0:0:0:0:0:1', 1, 20120228, '02:16:34', 14, 9999, 0, 'USUARIO: ADMIN', NULL);
INSERT INTO log VALUES (119, '0:0:0:0:0:0:0:1', 1, 20120228, '02:16:50', 12, 9999, 0, 'USUARIO: TESTEERRO: Ocorreu um erro ao tentar enviar mensagem com a senha para o usuário.', NULL);


SET search_path = acesso, pg_catalog;

--
-- TOC entry 1905 (class 2606 OID 77684)
-- Dependencies: 1588 1588
-- Name: permissao_pkey; Type: CONSTRAINT; Schema: acesso; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY permissao
    ADD CONSTRAINT permissao_pkey PRIMARY KEY (idpermissao);


--
-- TOC entry 1911 (class 2606 OID 77686)
-- Dependencies: 1593 1593
-- Name: pk_usuario; Type: CONSTRAINT; Schema: acesso; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY usuario
    ADD CONSTRAINT pk_usuario PRIMARY KEY (idusuario);


--
-- TOC entry 1907 (class 2606 OID 77688)
-- Dependencies: 1590 1590
-- Name: site_pkey; Type: CONSTRAINT; Schema: acesso; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY site
    ADD CONSTRAINT site_pkey PRIMARY KEY (idsite);


--
-- TOC entry 1909 (class 2606 OID 77690)
-- Dependencies: 1591 1591
-- Name: tipousuario_pkey; Type: CONSTRAINT; Schema: acesso; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY tipousuario
    ADD CONSTRAINT tipousuario_pkey PRIMARY KEY (idtipousuario);


--
-- TOC entry 1913 (class 2606 OID 77692)
-- Dependencies: 1593 1593
-- Name: usuario_login_key; Type: CONSTRAINT; Schema: acesso; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY usuario
    ADD CONSTRAINT usuario_login_key UNIQUE (login);


SET search_path = data, pg_catalog;

--
-- TOC entry 1921 (class 2606 OID 77858)
-- Dependencies: 1606 1606
-- Name: elegibilidade_dados_pkey; Type: CONSTRAINT; Schema: data; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY elegibilidade_dados
    ADD CONSTRAINT elegibilidade_dados_pkey PRIMARY KEY (idelegibilidade_dados);


--
-- TOC entry 1923 (class 2606 OID 77888)
-- Dependencies: 1608 1608
-- Name: elegibilidade_pkey; Type: CONSTRAINT; Schema: data; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY elegibilidade
    ADD CONSTRAINT elegibilidade_pkey PRIMARY KEY (idelegibilidade);


SET search_path = log, pg_catalog;

--
-- TOC entry 1915 (class 2606 OID 77694)
-- Dependencies: 1597 1597
-- Name: acao_pkey; Type: CONSTRAINT; Schema: log; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY acao
    ADD CONSTRAINT acao_pkey PRIMARY KEY (idacao);


--
-- TOC entry 1917 (class 2606 OID 77696)
-- Dependencies: 1599 1599
-- Name: forms_pkey; Type: CONSTRAINT; Schema: log; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY form
    ADD CONSTRAINT forms_pkey PRIMARY KEY (idform);


--
-- TOC entry 1919 (class 2606 OID 77698)
-- Dependencies: 1601 1601
-- Name: log_pkey; Type: CONSTRAINT; Schema: log; Owner: positrot; Tablespace: 
--

ALTER TABLE ONLY log
    ADD CONSTRAINT log_pkey PRIMARY KEY (idlog);


SET search_path = acesso, pg_catalog;

--
-- TOC entry 1924 (class 2606 OID 77699)
-- Dependencies: 1590 1593 1906
-- Name: usuario_fk; Type: FK CONSTRAINT; Schema: acesso; Owner: positrot
--

ALTER TABLE ONLY usuario
    ADD CONSTRAINT usuario_fk FOREIGN KEY (site) REFERENCES site(idsite) ON UPDATE CASCADE;


--
-- TOC entry 1925 (class 2606 OID 77704)
-- Dependencies: 1593 1588 1904
-- Name: usuario_permissao_fk; Type: FK CONSTRAINT; Schema: acesso; Owner: positrot
--

ALTER TABLE ONLY usuario
    ADD CONSTRAINT usuario_permissao_fk FOREIGN KEY (tipoacesso) REFERENCES permissao(idpermissao) ON UPDATE CASCADE;


--
-- TOC entry 1926 (class 2606 OID 77709)
-- Dependencies: 1593 1591 1908
-- Name: usuario_tipousuario_fk; Type: FK CONSTRAINT; Schema: acesso; Owner: positrot
--

ALTER TABLE ONLY usuario
    ADD CONSTRAINT usuario_tipousuario_fk FOREIGN KEY (tipo) REFERENCES tipousuario(idtipousuario) ON UPDATE CASCADE;


SET search_path = data, pg_catalog;

--
-- TOC entry 1930 (class 2606 OID 77889)
-- Dependencies: 1920 1608 1606
-- Name: elegibilidade_elegibilidadedados_fk; Type: FK CONSTRAINT; Schema: data; Owner: positrot
--

ALTER TABLE ONLY elegibilidade
    ADD CONSTRAINT elegibilidade_elegibilidadedados_fk FOREIGN KEY (idelegibilidade_dados) REFERENCES elegibilidade_dados(idelegibilidade_dados) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1932 (class 2606 OID 77899)
-- Dependencies: 1608 1906 1590
-- Name: elegibilidade_site_fk; Type: FK CONSTRAINT; Schema: data; Owner: positrot
--

ALTER TABLE ONLY elegibilidade
    ADD CONSTRAINT elegibilidade_site_fk FOREIGN KEY (site) REFERENCES acesso.site(idsite) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1931 (class 2606 OID 77894)
-- Dependencies: 1910 1608 1593
-- Name: elegibilidade_usuario_fk; Type: FK CONSTRAINT; Schema: data; Owner: positrot
--

ALTER TABLE ONLY elegibilidade
    ADD CONSTRAINT elegibilidade_usuario_fk FOREIGN KEY (digitador) REFERENCES acesso.usuario(idusuario) ON UPDATE CASCADE;


SET search_path = log, pg_catalog;

--
-- TOC entry 1927 (class 2606 OID 77714)
-- Dependencies: 1601 1597 1914
-- Name: log_acao_fk; Type: FK CONSTRAINT; Schema: log; Owner: positrot
--

ALTER TABLE ONLY log
    ADD CONSTRAINT log_acao_fk FOREIGN KEY (idacao) REFERENCES acao(idacao);


--
-- TOC entry 1928 (class 2606 OID 77719)
-- Dependencies: 1601 1916 1599
-- Name: log_form_fk; Type: FK CONSTRAINT; Schema: log; Owner: positrot
--

ALTER TABLE ONLY log
    ADD CONSTRAINT log_form_fk FOREIGN KEY (idform) REFERENCES form(idform) ON UPDATE CASCADE;


--
-- TOC entry 1929 (class 2606 OID 77724)
-- Dependencies: 1593 1601 1910
-- Name: log_usuario_fk; Type: FK CONSTRAINT; Schema: log; Owner: positrot
--

ALTER TABLE ONLY log
    ADD CONSTRAINT log_usuario_fk FOREIGN KEY (idusuario) REFERENCES acesso.usuario(idusuario) ON UPDATE CASCADE;


--
-- TOC entry 1946 (class 0 OID 0)
-- Dependencies: 6
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


-- Completed on 2012-03-01 22:22:35

--
-- PostgreSQL database dump complete
--

